package engine.entities;

import engine.entities.MobClass.MobClass;
import engine.entities.attribute.MobStatSet;
import engine.entities.inventory.item.MobEquipSet;
import engine.game.Game;
import engine.game.InputHandler;
import engine.game.level.Level;

public class Player extends Mob {

    private boolean inputLock = false;
    private final InputHandler input;
    private final Game game;

    public Player(Level level, InputHandler input, MobClass mobClass, MobStatSet stats, MobEquipSet equipSet) {
        super(level, "Jip", mobClass, stats, equipSet);
        this.input = input;
        this.game = Game.getGlobalGame();
    }

    @Override
    public void tick() {
        super.tick();

        if (doingAnim) {
            return;
        }
        
        if (!inCombat && !inputLock &&!game.inventoryOpen()) {
            if (input.up.isPressed()) {
                ya--;
            }
            if (input.down.isPressed()) {
                ya++;
            }
            if (input.left.isPressed()) {
                xa--;
            }
            if (input.right.isPressed()) {
                xa++;
            }

            if (((xa != 0) || (ya != 0)) && !moving) {
                if (ya != 0) move(0, ya);
                else move(xa, 0);
            }
        }
    }
    
    @Override
    public boolean isFriendsWith(Mob other) {
        return other instanceof Player;
    }
    
    public void setInputLock(boolean lock) {
        this.inputLock = lock;
    }
    
}
